<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <i class="el-icon-lx-cascades"></i> 订单管理
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-input v-model="query.mobile"  placeholder="手机号"  class="handle-input mr10"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
                <span>共提现: {{totalWithdraw}}</span>
                <el-button type="danger"  style="float: right" icon="el-icon-download" @click="downFile">导出文件</el-button>
            </div>
            <el-table
                :data="tableData"
                border
                class="table"
                ref="multipleTable"
                header-cell-class-name="table-header"
            >
                <el-table-column prop="id" label="Id" width="55" align="center"></el-table-column>
                <el-table-column prop="mobile" label="手机号"></el-table-column>
                <el-table-column prop="nickname" label="微信昵称"></el-table-column>
                <el-table-column prop="amount" label="提现金额"></el-table-column>
                <el-table-column prop="real_name" label="支付宝名称"></el-table-column>
                <el-table-column prop="zfb_account" label="支付宝账户"></el-table-column>
                <el-table-column prop="create_time" label="提交时间"></el-table-column>
                <el-table-column label="操作" width="180" align="center">
                    <template slot-scope="scope">
                        <el-button
                            type="text"
                            v-if="scope.row.status == 0"
                            icon="el-icon-check"
                            @click="confirmOk(scope.$index, scope.row)"
                        >确认转账</el-button>
                        <span  v-if="scope.row.status == 1">已转账</span>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination">
                <el-pagination
                    background
                    layout="prev, next, pager"
                    :current-page="query.page"
                    :page-size="query.pageSize"
                    :total="pageTotal"
                    @current-change="handlePageChange"
                ></el-pagination>
            </div>
        </div>
    </div>
</template>

<script>

export default {
    name: 'order',
    data() {
        return {
            query: {
                page: 1,
                pageSize: 10,
            },
            tableData: [],
            pageTotal: 0,
            totalWithdraw: 0,
        };
    },
    created() {
        this.getData();
    },
    methods: {
        getData() {
            this.http.withdraw(this.query).then(res => {
                if(res.code ===  0) {
                    this.tableData = res.data.data;
                    this.pageTotal = res.data.total;
                    this.totalWithdraw = res.data.totalWithdraw;
                } else {
                    this.$message.error(res.msg);
                }
            });
        },
        // 触发搜索按钮
        handleSearch() {
            this.$set(this.query, 'page', 1);
            this.getData();
        },
        downFile() {
            window.open('/admin/withdraw_excel?mobile=' + this.query.mobile)
        },

        // 编辑操作
        confirmOk(index, row) {
            this.http.doWithdraw({id: row.id}).then(res => {
                this.getData();
            });
        },
        // 分页导航
        handlePageChange(val) {
            this.$set(this.query, 'page', val);
            this.getData();
        }
    }
};
</script>

<style scoped>
.handle-box {
    margin-bottom: 20px;
}

.handle-select {
    width: 120px;
}

.handle-input {
    width: 300px;
    display: inline-block;
}
.table {
    width: 100%;
    font-size: 14px;
}
.red {
    color: #ff0000;
}
.mr10 {
    margin-right: 10px;
}
.table-td-thumb {
    display: block;
    margin: auto;
    width: 40px;
    height: 40px;
}
</style>
